#include <stdlib.h>
#include "dqueue.h"


dqueue_t *deque_new(int maxsize)
{
    dqueue_t *q = malloc(sizeof(dqueue_t));
    if (q == NULL)
        return NULL;

    q->in  = queue_new(maxsize);
    if (q->in == NULL)
        goto free_q;

    q->out = queue_new(maxsize);
    if (q->out == NULL)
        goto free_in;

    return q;

free_in:
    free(q->in);
free_q:
    free(q);
    return NULL;
}

void dqueue_del(dqueue_t *q)
{
    queue_del(q->out);
    queue_del(q->in);
    free(q);
}
